# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Monitoring.V3.Model.SqlCondition do
  @moduledoc """
  A condition that allows alerting policies to be defined using GoogleSQL. SQL conditions examine a sliding window of logs using GoogleSQL. Alert policies with SQL conditions may incur additional billing.

  ## Attributes

  *   `booleanTest` (*type:* `GoogleApi.Monitoring.V3.Model.BooleanTest.t`, *default:* `nil`) - Test the boolean value in the indicated column.
  *   `daily` (*type:* `GoogleApi.Monitoring.V3.Model.Daily.t`, *default:* `nil`) - Schedule the query to execute every so many days.
  *   `hourly` (*type:* `GoogleApi.Monitoring.V3.Model.Hourly.t`, *default:* `nil`) - Schedule the query to execute every so many hours.
  *   `minutes` (*type:* `GoogleApi.Monitoring.V3.Model.Minutes.t`, *default:* `nil`) - Schedule the query to execute every so many minutes.
  *   `query` (*type:* `String.t`, *default:* `nil`) - Required. The Log Analytics SQL query to run, as a string. The query must conform to the required shape. Specifically, the query must not try to filter the input by time. A filter will automatically be applied to filter the input so that the query receives all rows received since the last time the query was run.For example, the following query extracts all log entries containing an HTTP request:SELECT timestamp, log_name, severity, http_request, resource, labels FROM my-project.global._Default._AllLogs WHERE http_request IS NOT NULL
  *   `rowCountTest` (*type:* `GoogleApi.Monitoring.V3.Model.RowCountTest.t`, *default:* `nil`) - Test the row count against a threshold.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :booleanTest => GoogleApi.Monitoring.V3.Model.BooleanTest.t() | nil,
          :daily => GoogleApi.Monitoring.V3.Model.Daily.t() | nil,
          :hourly => GoogleApi.Monitoring.V3.Model.Hourly.t() | nil,
          :minutes => GoogleApi.Monitoring.V3.Model.Minutes.t() | nil,
          :query => String.t() | nil,
          :rowCountTest => GoogleApi.Monitoring.V3.Model.RowCountTest.t() | nil
        }

  field(:booleanTest, as: GoogleApi.Monitoring.V3.Model.BooleanTest)
  field(:daily, as: GoogleApi.Monitoring.V3.Model.Daily)
  field(:hourly, as: GoogleApi.Monitoring.V3.Model.Hourly)
  field(:minutes, as: GoogleApi.Monitoring.V3.Model.Minutes)
  field(:query)
  field(:rowCountTest, as: GoogleApi.Monitoring.V3.Model.RowCountTest)
end

defimpl Poison.Decoder, for: GoogleApi.Monitoring.V3.Model.SqlCondition do
  def decode(value, options) do
    GoogleApi.Monitoring.V3.Model.SqlCondition.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Monitoring.V3.Model.SqlCondition do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
